<%@ page import="java.sql.*" %><%--
  Created by IntelliJ IDEA.
  User: MS
  Date: 2022/7/8
  Time: 16:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>个人信息</title>
  <link href="css/bootstrap.min.css" rel="stylesheet">
  <link href="css/animate.min.css" rel="stylesheet">
  <link href="css/styles.css" rel="stylesheet">
</head>
<style>
  body{
    background:url(image/背景图.jpg) no-repeat center top;
    background-size:cover;
    background-attachment:fixed;
  }
  form{
    align-content: center;
    color: white;
    border: 3px solid #ffdd00;

  }
  .person-box{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    width: 400px;
    padding:40px;
    background: rgba(0,0,0,.8);
    box-sizing: border-box;
    box-shadow: 0 15px  25px rgba(0,0,0,.5);
    border-radius: 10px;}
    button{
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    background: #03a9f4;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 5px;
  }
  h2{
    color: whitesmoke;
  }
</style>
<body>
<header style="background: #0B0B0B">
  <nav id="main-nav" class="navbar navbar-default navbar-fixed-top" role="banner">
    <div class="container">
      <div class="navbar-header">
        <a class="navbar-brand" ><img src="image/logo.png" alt="logo"></a>
      </div>

      <div class="collapse navbar-collapse navbar-right">
        <ul class="nav navbar-nav">
          <li class="scroll"><a href="index.jsp">首页</a></li>
          <li class="scroll active"><a href="person_message.jsp">修改个人信息</a></li>
          <li class="scroll"><a href="OrderServlet">我的订单</a></li>
          <li class="scroll"><a href="#">联系客服</a></li>
        </ul>
      </div>
    </div>
  </nav></header>
<br>
<br>
<br>
<div class="person-box">
  <h2>个人信息</h2>
  <jsp:useBean id="loginBean" class="bean.Login" scope="session"/>
  <%!
    String userID;
    String Tel;
    String Email;
    String Sex;
    String Birth;
  %>
  <%
    if (loginBean==null){
      response.sendRedirect("login.jsp");
      return;
    }else {
      boolean b=loginBean.getLoginID()==null||loginBean.getLoginID().length()==0;
      if (b){
        response.sendRedirect("login.jsp");
        return;
      }
    }
    userID=loginBean.getLoginID();
  %>
  <%
    Connection con=null;
    Statement sql;
    ResultSet rs;
//    Context context=new InitialContext();
//    Context contextNeeded =(Context) context.lookup("java:comp/env");
//    DataSource ds=(DataSource) contextNeeded.lookup("hotelConn");
    String driver="org.mariadb.jdbc.Driver";
    String url="jdbc:mariadb://localhost:3306/hotel-management-system";
    try {
      Class.forName(driver);
      con= DriverManager.getConnection(url,"root","123456");
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
    try {
//        con=ds.getConnection();
      assert con != null;
      sql=con.createStatement();
      //读取酒店详情表
      String ex="select * from users where UserID='"+userID+"'";
      rs=sql.executeQuery(ex);

      while (rs.next()){

        userID=rs.getString("UserID");
        Tel=rs.getString("Tel");
        Email=rs.getString("Email");
        Sex=rs.getString("Sex");
        Birth=rs.getString("Birth");
//        Password=rs.getString("Password");
      }
    }catch (SQLException e){
      System.out.print(e);
    }
    finally {
      try {
        assert con != null;
        con.close();
      }catch (Exception e){
        System.out.print(e);
      }
    }

  %>
  <form align="center" action="person_message.jsp">
    用户名：<input type="text"  style="color: #0B0B0B" name="UserID" value="<%=userID%>">
    <br>
    <br>
    手机：<input type="text" style="color: #0B0B0B" name="Tel" value=<%=Tel%>>
    <br>
    <br>
    邮箱：<input type="text" style="color: #0B0B0B" name="Email" value=<%=Email%>>
    <br>
    <br>
    性别：<input type="text" style="color: #0B0B0B" name="Sex" value=<%=Sex%> >
    <br>
    <br>
    生日：<input type="text" style="color: #0B0B0B" name="Birth" value=<%=Birth%>>
    <br><br>
    <input type="submit" value="点击修改信息"/>
  </form></div>
</body>
</html>
